﻿/*
    创建开始节点
*/
function createStartNode() {
    createtNode("Images/start.png", "actStart", 72, 72);
}
/*
    创建活动节点
*/
function createActNode() {
    createtNode("Images/act.png", "actCommon", 100, 70);
}
/*
    创建条件分支节点
*/
function createOrSplitNode() {
    createtNode("Images/orSplit.png", "routeOrSplit", 72, 72);
}
/*
    创建并行分支节点
*/
function createAndSplitNode() {
    createtNode("Images/andSplit.png", "routeAndSplit", 72, 72);
}
/*
    创建异或分支节点
*/
function createXorSplitNode() {
    createtNode("Images/xorSplit.png", "routeXorSplit", 72, 72);
}
/*
    创建结束节点
*/
function createEndNode() {
    createtNode("Images/end.png", "actEnd", 72, 72);
}
/*
    创建条件合并节点
*/
function createOrJoinNode() {
    createtNode("Images/orJoin.png", "routeOrJoin", 72, 72);
}
/*
    创建并行合并节点
*/
function createAndJoinNode() {
    createtNode("Images/andJoin.png", "routeAndJoin", 72, 72);
}
/*
    创建异或合并节点
*/
function createXorJoinNode() {
    createtNode("Images/xorJoin.png", "routeXorJoin", 72, 72);
}

/*
    创建回退节点
*/
function createRollbackNode() {
    createtNode("Images/rollback.png", "actRollback", 72, 72);
}

function createtNode(img,actType,width,heigth) {
    var act = document.createElement("wfact");
    act.id = "node" + (latestNodeId++);
    act.className = "draggable";
    act.className += " block actname ";
    act.style.left = "10px";
    act.style.top = "10px";
    act.style.height = heigth+"px";
    act.style.width = width + "px";
    if (actType == "actCommon") {
        act.innerHTML = "新活动";
        act.setAttribute("wfname", "");
    } else {
        act.setAttribute("wfname", "新活动");
        act.innerHTML = "&nbsp;&nbsp;&nbsp;";
    }
    act.setAttribute("wfmodule", "");
    act.setAttribute("wfmoddesc", "");
    act.setAttribute("wftype", actType);
    if (actType == "routeOrSplit") {
        act.setAttribute("wfin", "Y");
    } else {
        act.setAttribute("wfin", "N");
    }
    act.setAttribute("wfout", "N");
    act.setAttribute("wfuserid", "");
        
    act.style.background = "url(" + img + ")";
    act.onmousedown = startDrag;
    act.onmouseup = stopDrag;
    act.onclick = function () {
    mageMttrs(act);
};
    $id("mainCanvas_innerDiv").appendChild(act);

    //------------动态添加到画布------------
    var canvas = findCanvas('mainCanvas');
    var newBlock = new Block(act, canvas);
    newBlock.initBlock();
    canvas.blocks.push(newBlock);
    //------------动态添加到画布--end------
    }

function deleteAct() {
    var actId = $id("id_ipt_attr_id").value;
    if (actId == null || actId == "") return;
    deleteNode(actId);
}